package com.example.idemfactor.sdk.handler;

import com.example.idemfactor.sdk.exception.IdemfactorException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

@RestControllerAdvice
public class IdemfactorExceptionHandler {
    @ExceptionHandler(value = IdemfactorException.class)
    public Map<String, Object> idemfactorExceptionHandler(IdemfactorException e) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", null);
        map.put("msg", e.getMsg());
        map.put("code", e.getCode());
        return map;
    }
}
